home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / HippoDraw / hippo / h_test.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-28  |  1.2 KB  |  67 lines

  1. #include <math.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include "hippo.h"
  5.  
  6. int main()
  7. {
  8.      ntuple *nt_list;
  9.      display *d_list;
  10.      FILE *outfile;
  11.      int nnt;
  12.      
  13.      /*
  14.       * read in example ntuple
  15.       */
  16.      if (h_read("example.hippo",&d_list,&nt_list) != 0)
  17.      {
  18.       fprintf(stderr,"Error reading file example.hippo\n");
  19.       exit(1);
  20.      }
  21.  
  22.      /*
  23.       * check a few things
  24.       */
  25.      for (nnt=0; nt_list[nnt] != NULL; nnt++);
  26.      if (nnt != 1)
  27.      {
  28.       fprintf(stderr,"There are %d ntuples in the file\n",nnt);
  29.       fprintf(stderr,"  There should only be 1!\n");
  30.       exit(1);
  31.      }
  32.      
  33.      /*
  34.       * create display
  35.       */
  36.      if ((d_list[0] = h_newDisp(HISTOGRAM)) == NULL)
  37.      {
  38.       fprintf(stderr,"Error creating display\n");
  39.       exit(1);
  40.      }
  41.      
  42.      /*
  43.       * set display attributes
  44.       */
  45.      h_setBinNum(d_list[0],XAXIS,10);
  46.      h_bindNtuple( d_list[0], nt_list[0] );
  47.      h_bind(d_list[0],XAXIS, 1);
  48.      
  49.      /*
  50.       * create line printer output of display
  51.       */
  52.  
  53.      outfile = fopen("h_test.out2","w");
  54.      h_fprint(d_list[0],outfile);
  55.  
  56.      /*
  57.       * clean up and exit
  58.       */
  59.      fclose(outfile);
  60.      h_freeDisp(d_list[0]);
  61.      h_freeNt(nt_list[0]);
  62.      free(nt_list);
  63.      free(d_list);
  64.  
  65.      exit(0);
  66. }
  67.